//
//  DCWUserDefaultHelper.m
//  Meng800
//
//  Created by 姚宗超 on 14-7-30.
//  Copyright (c) 2014年 点财网. All rights reserved.
//

#import "MPUserDefaultHelper.h"
#import "MPDeviceObject.h"
#import "NSString+Common.h"

@implementation MPUserDefaultHelper

+ (BOOL)saveParamToUserDefault
{
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    MPDeviceObject* device = [MPDeviceObject sharedInstance];
    [userDefaults setBool:device.isFirstLogin forKey:@"isFirstLogin"];
    [userDefaults setObject:device.bRegisterUserId forKey:@"bRegisterUserId"];
    [userDefaults setObject:device.bRegisterChannelId forKey:@"bRegisterChannelId"];
    [userDefaults setObject:device.bRegisterAppId forKey:@"bRegisterAppId"];
    
    //这里建议同步存储到磁盘中，但是不是必须的
    return [userDefaults synchronize];
}

+ (void)readParamFromUserDefault
{
    // 注册默认值
    NSDictionary *userDefaultsDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
                                          [NSNumber numberWithBool:YES], @"isFirstLogin",
                                          nil];
    NSUserDefaults *userDefaultes = [NSUserDefaults standardUserDefaults];
    [userDefaultes registerDefaults:userDefaultsDefaults];
    [[MPDeviceObject sharedInstance] setupUserDefaultDataWithInfo:[userDefaultes dictionaryRepresentation]];
}

@end
